﻿using System.Collections;
using UnityEngine;

namespace UFrame
{
    /// <summary>
    /// 代表每一个关卡， 管理怪物是否被销毁和创建
    /// 逻辑混乱应该删除
    /// </summary>
    public class LevelMaMono : MaMono<LevelMaMono>
    {
        public Transform playerCreatePos;

        public Transform bossCreatePos;

        // Use this for initialization
        protected void Start()
        {
            EventMa.Register(ABLoadCompleteArgs.EventId, OnLoadSceneAB);
            EventMa.Register(EndLoadEndSceneArgs.EventId, OnLoadSceneEnd);
            EventMa.Register(UFrameInitArgs.EventId, OnInitFrame);
            isInit = true;
        }

        public void OnInitFrame()
        {
            //StartCoroutine(SceneMa.I.LoadScene("Boss12"));
        }

        public void OnLoadSceneAB()
        {
            //StartCoroutine(SceneMa.I.LoadScene("Boss12"));
        }

        public void OnLoadSceneEnd()
        {
            StartCoroutine(StartCreateEntity());
        }

        public IEnumerator StartCreateEntity()
        {
            yield return new WaitForSeconds(1f);
        }

        public GameObject InstanceObj(GameObject go)
        {
            GameObject newGo = GameObject.Instantiate(go);
            newGo.transform.SetParent(GameFrameWorkMa.I.entity, false);
            return newGo;
        }

        protected override void OnDestroy()
        {
            EventMa.Unregister(ABLoadCompleteArgs.EventId, OnLoadSceneEnd);
        }
    }
}